// import { useAppState } from "@/store/appState";
import axios from "axios";

// const isPro: boolean = process.env.NODE_ENV === "production";
// const baseUrl = "https://mr-stage.sensetime.com/api";

export const request = axios.create({
  // baseURL: `${baseUrl}${url}`,
  baseURL: `/api`,
  timeout: 2000,
});

request.interceptors.response.use(
  (response) => {
    console.log(response);
    return response.data;
  },
  (error) => {
    return Promise.reject(error);
  }
);

export const get = <T = unknown>(url: string, data: unknown, headers?: any) => {
  return request.get<any, BaseResponse<T>>(url, {
    params: data,
    headers: headers,
  });
};

export const post = <T = BaseResponse>(
  url: string,
  data: unknown,
  headers?: any
) => {
  return request.post<any, BaseResponse<T>>(url, data, {
    headers,
  });
};

export const put = <T = BaseResponse>(
  url: string,
  data: unknown,
  headers?: any
) => {
  return request.put<any, BaseResponse<T>>(url, data, {
    headers,
  });
};

export const deletee = <T = BaseResponse>(
  url: string,
  data: unknown,
  headers?: any
) => {
  return request.delete<any, BaseResponse<T>>(url, {
    data,
    headers,
  });
};
